<%@ LANGUAGE="VBSCRIPT" %>
<%
	'response.write Session("VanBan")
	if Instr(Session("VanBan"),"-"& Request("IDFlow") &"-")=0 or Session("VanBan")="" then
		Response.Redirect(Session("URL")& "Error.asp?ErrorCode=3")
	end if
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\RootContent.inc"-->
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<Title>Hệ Quản Trị Văn Thư</Title>
<%	
	bFileName=request("Filename")
	Set File = Server.CreateObject("ActiveFile.File")
	bMa=Request("bMa")
	IDFlow=Request("IDFlow")
	Set File = Nothing
	bComm=Request("bComm")	
	'bg thphuc 22-02-03
	sSQL="select distinct workflow.trangthai from workflow inner join flownode on workflow.maworkflow=flownode.maworkflow where flownode.trangthaixl=2 and workflow.maworkflow like '"& IDFlow &"' and workflow.trangthai=0"
		Set RecKtWorkflow=Server.CreateObject("ADODB.Recordset")
		RecKtWorkflow.CursorType=3
		RecKtWorkflow.CacheSize=5
		RecKtWorkflow.Open sSQL,Conn
			if RecKtWorkflow.recordcount > 0 then
				sSQL="update workflow set trangthai=1 where maworkflow like '"& IDFlow &"'"
				Conn.Execute sSQL
			end if
		RecKtWorkflow.Close
		set RecKtWorkflow	= nothing
	'ed thphuc 22-02-03
	if bComm="ok" then
		bMa=Request("bMa")
		Set ClsFile=server.CreateObject("Vinalines.ClsFile")
		Set RecCopy=server.createobject("ADODB.Recordset")
		sSQL="Select * from flownode where Maworkflownode like '"& bMa &"'"
		RecCopy.cursortype=3
		RecCopy.CatcheSize=5
		RecCopy.open sSQL,Conn		
		if (not RecCopy.Eof) and (not RecCopy.BOF) then
			'bg thphuc xu ly ykien
			'bmaWorkflow=RecCopy("Maworkflow")
			
			'bYkien=RecCopy("Ykien")	 '22_1
			Set ClsNodeFile=server.CreateObject("Vinalines.ClsFile")
			bNodeFile=RootContent & "Data\Xuly\Text\" & trim(bMa) & ".VT"
			bYkien=ClsNodeFile.ReadTextFile(bNodeFile)
			Set ClsNodeFile=nothing

			'bFile=RootContent & "Data\Yeucau\Text\" & trim(bMaworkflow) & ".VT"
			bFile=RootContent & "Data\Yeucau\Text\" & trim(IDFlow) & ".VT"
			'ed thphuc xu ly y kien
			bText=ClsFile.ReadTextFile(bFile) & "<font face=Arial color=blue><Strong>"& Layten(RecCopy("Nguoixuly")) &"</Strong><pre>"& bYkien & "</pre>" 							
			ClsFile.SaveFile bText,bFile
			sSQL="Update flownode set thuhoi=1 where maworkflownode='"& bMa &"'"
			Conn.Execute sSQL
		end if
		Set ClsFile=nothing
		RecCopy.close
		set RecCopy=nothing
	end if
%>
<Script language=javascript>
	function CopyTo(bMa){
		frm.action="Xemykientongthe.asp?bComm=ok&IDFlow=<%=IDFlow%>&bma="+bMa;
		frm.submit();	
	}
    </Script>
<Body topmargin=0 leftmargin=0 bgcolor=#F8F9D9 style="font-family: Arial">
	<form name=frm method=post>
		<P ALIGN=CENTER><FONT FACE=TAHOMA COLOR=BLUE SIZE=4><U>TỔNG HỢP Ý KIẾN</U></FONT>
		<p align=right>
		<%'report(IDFlow)%>
		<%
	Set Rec=server.CreateObject("ADODB.Recordset")
	Rec.CursorType=3
	Rec.CacheSize=5
	sSQL="Select * from flownode where  Maworkflow = '"& IDFlow &"' order by maworkflownode"
	sSQL="SELECT     *  FROM         dbo.Workflow INNER JOIN                       dbo.FlowNode ON dbo.Workflow.MaWorkFlow = dbo.FlowNode.MaWorkflow WHERE     (dbo.Workflow.MaWorkFlow =  '"& IDFlow &"')"
	Rec.Open sSQL,Conn
	dorong=5
	Do while not Rec.EOF
		bCurrent=Rec("maworkflownode")
		bW=100-(ItemLast(bCurrent)*dorong-2*dorong)
		if isnull(Rec("Maworkflowcon")) then			

'			if not isnull(Rec("ykien")) then		'22_1
'				bykien=Rec("ykien")
'				bMaW=Rec("Maworkflownode")				
'			else
'				bykien=""
'				bMaW=Rec("Maworkflownode")
'			end if

			bNodeFile=RootContent & "Data\Xuly\Text\" & trim(bCurrent) & ".VT"
			Set ClsNodeFile=server.CreateObject("Vinalines.ClsFile")
			bYkien=ClsNodeFile.ReadTextFile(bNodeFile)
			Set ClsNodeFile=nothing
			bMaW=Rec("Maworkflownode")

			bThuhoi=Rec("Thuhoi")
			if bThuhoi then 
				bDis="disabled"
				bLabel="Đã thu hồi"
			else
				bDis=""
				bLabel="Thu hồi"
			end if
			if Rec("yeucauxl")="1" then
				if rec("Trangthaixl")=2 then	
					'bg thphuc xu ly yeucau
					if Rec("phanhoi") then %>
						<Table border=0 cellspacing=0 cellpadding=0 width='<%= bW%>%'><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font><!-- <input type=button <%=bDis%> language=javascript onclick="return CopyTo('<%=bmaW%>')" name=CmdCopy value='<%=bLabel%>' style="font-family:Arial"> --><pre style='font-family:Arial;font-size:14'><%=bykien%></pre></TD></Table>
						<%
						Set File = Server.CreateObject("ActiveFile.File")
						Path=RootContent & "Data\Xuly\TEXT\" & trim(bCurrent) & ".VT"
						File.Name=Path
						if File.Exists() then
							sSQL="Select Tentep,mota from flownode_Tentep where Maflownode like '"& bCurrent & "'"
							Set RecT=server.CreateObject("ADODB.Recordset")
							RecT.CursorType=3
							RecT.CacheSize=5
							RecT.Open sSQL,Conn	
							bAttach=""
							if RecT.RecordCount then
								'bAttach="<hr>"
								bAttach=bAttach & "<center><Table><TR>"
								bCol=0
								Do while not RecT.EOF
										if bCol=5 then
											bAttach=bAttach & "</TR><TR>"
											bCol=0
										end if
										bAttach=bAttach & "<TD Width=135 ><A href=OpenAttach.asp?FromThuhoi=true&filename="& Session("ClsFun").mahoa(lcase(RecT("Tentep"))) & " target=New><center>"
										imgext =lcase(ExtFile(RecT("Tentep")))
										select case imgext
											case "doc"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\doc.gif"&" border=0>"
											case "xls"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\xls.gif"&" border=0>"
											case "gif","jpg","bmp","tif"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\gif.gif"&" border=0>"
											case "txt","log","bat"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\txt.gif"&" border=0>"
											case "html","htm"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\html.gif"&" border=0>"
											case "ppt"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\ppt.gif"&" border=0>"
											case "pdf"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\pdf.gif"&" border=0>"
											case "mdb"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\mdb.gif"&" border=0>"
											case "com","exe"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\exe.gif"&" border=0>"
											case "avi"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\avi.gif"&" border=0>"
											case else
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\other.gif"&" border=0>"
										end select
										bAttach=bAttach & "<br><font face=Arial size=2>" & RecT("Mota") & "</font></center></A></TD>"
										RecT.MoveNext
										bCol=bCol+1
								Loop
								bAttach=bAttach & "</TR></Table></center>"
								response.write bAttach
							end if
							RecT.Close
							Set RecT=nothing							
						end if
						Set File = Nothing
						%>
					<%else%>
						<Table border=0 cellspacing=0 cellpadding=0 width='<%= bW%>%'><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font> <!-- <input type=button <%=bDis%> language=javascript onclick="return CopyTo('<%=bmaW%>')" name=CmdCopy value='<%=bLabel%>' style="font-family:Arial"> --><pre style='font-family:Arial;font-size:14'><%=bykien%></pre></TD></Table>
						<%
						Set File = Server.CreateObject("ActiveFile.File")
						Path=RootContent & "Data\Xuly\TEXT\" & trim(bCurrent) & ".VT"
						File.Name=Path
						if File.Exists() then
							sSQL="Select Tentep,mota from flownode_Tentep where Maflownode like '"& bCurrent & "'"
							Set RecT=server.CreateObject("ADODB.Recordset")
							RecT.CursorType=3
							RecT.CacheSize=5
							RecT.Open sSQL,Conn	
							bAttach=""
							if RecT.RecordCount then
								'bAttach="<hr>"
								bAttach=bAttach & "<center><Table><TR>"
								bCol=0
								Do while not RecT.EOF
										if bCol=5 then
											bAttach=bAttach & "</TR><TR>"
											bCol=0
										end if
										bAttach=bAttach & "<TD Width=135 ><A href=OpenAttach.asp?FromThuhoi=true&filename="& Session("ClsFun").mahoa(lcase(RecT("Tentep"))) & " target=New><center>"
										imgext =lcase(ExtFile(RecT("Tentep")))
										select case imgext
											case "doc"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\doc.gif"&" border=0>"
											case "xls"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\xls.gif"&" border=0>"
											case "gif","jpg","bmp","tif"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\gif.gif"&" border=0>"
											case "txt","log","bat"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\txt.gif"&" border=0>"
											case "html","htm"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\html.gif"&" border=0>"
											case "ppt"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\ppt.gif"&" border=0>"
											case "pdf"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\pdf.gif"&" border=0>"
											case "mdb"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\mdb.gif"&" border=0>"
											case "com","exe"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\exe.gif"&" border=0>"
											case "avi"
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\avi.gif"&" border=0>"
											case else
												bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\other.gif"&" border=0>"
										end select
										bAttach=bAttach & "<br><font face=Arial size=2>" & RecT("Mota") & "</font></center></A></TD>"
										RecT.MoveNext
										bCol=bCol+1
								Loop
								bAttach=bAttach & "</TR></Table></center>"
								response.write bAttach
							end if
							RecT.Close
							Set RecT=nothing							
						end if
						Set File = Nothing
						%>
					<%end if
					'ed thphuc xu ly yeucau
			else
					if rec("Trangthaixl")=1 then	%>
						<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font><pre style='font-family:Arial;font-size:14'>&#208;ang x&#7917; l&#253;..</pre></TD></Table>	
					<%else%>
						<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font><pre style='font-family:Arial;font-size:14'>Ch&#432;a x&#7917; l&#253;</pre></TD></Table>
<%				end if
				end if
			else
				if rec("Trangthaixl")=2 then	%>
					<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font><pre style='font-family:Arial;font-size:14'>&#208;&#227; xem</pre></TD></Table>							
				<%else%>
					<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#F8F9D9 width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></Strong></font><pre style='font-family:Arial;font-size:14'>Ch&#432;a xem</pre></TD></Table>
				<%end if
			end if%>			
			<Table border=0 cellspacing=0 cellpadding=0 height=2 width='100%'><TD width='100%'></TD></Table>
<%		else
			'bg thphuc xu ly yeu cau
			'if not rec("phanhoi") then
			if not rec("uyquyen") then
			'ed thphuc xu ly yeu cau
			%>
				<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#eeeecc width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></strong> (Đã uỷ quyền)</font></TD></Table>
					
			<%else
				sSQL="Select * from flownode where maworkflow like '"& Rec("maworkflowcon") &"'  order by maworkflownode"
				Set RecW=server.CreateObject("ADODB.Recordset")
				RecW.CursorType=3
				RecW.CacheSize=5
				RecW.Open sSQL,Conn%>	
				<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW  %>%"><TD bgcolor=#eeeecc width='<%= bW  %>%'><font face=Arial color=blue><Strong><%=Layten(Rec("Nguoixuly"))%></strong> (&#273;&#227; chuy&#7875;n cho nh&#7919;ng ng&#432;&#7901;i sau x&#7917; l&#253;)</font></TD></Table>
				<%
				'bg thphuc sua xu ly yeu cau
				Do While not RecW.EOF
					bCurrent=RecW("maworkflownode")
					'bW=100-(ItemLast(bCurrent)*dorong-2*dorong)
					bW1=bW-(ItemLast(bCurrent)*dorong-1*dorong)
					
					'if not isnull(RecW("ykien")) then
					'	bykien=RecW("ykien")
					'	bMaW1=RecW("maworkflownode")
					'else
					'	bykien=""
					'	bMaW1=RecW("maworkflownode")
					'end if

					bNodeFile=RootContent & "Data\Xuly\Text\" & trim(bCurrent) & ".VT"
					Set ClsNodeFile=server.CreateObject("Vinalines.ClsFile")
					bYkien=ClsNodeFile.ReadTextFile(bNodeFile)
					Set ClsNodeFile=nothing					
					bMaW1=RecW("maworkflownode")

					bThuhoi=RecW("Thuhoi")
					if bThuhoi then 
						bDis="disabled"
						bLabel="Đã thu hồi"
					else
						bDis=""
						bLabel="Thu hồi"
					end if
					if RecW("yeucauxl")="1" then
						if RecW("trangthaixl")=2 then%> 
							<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW1  %>%"><TD bgcolor=#eeeecc width="<%= bW1  %>%"><font face=Arial color=blue><Strong><%=Layten(RecW("Nguoixuly"))%></Strong><!-- </font><input type=button <%=bDis%> language=javascript onclick="return CopyTo('<%=bmaW1%>')" name=CmdCopy value='<%=bLabel%>' style="font-family:Arial"> --><pre style='font-family:Arial ;font-size:14'><%=bykien%></pre></TD></Table>
							<%
							'23_1
							Set File = Server.CreateObject("ActiveFile.File")
							Path=RootContent & "Data\Xuly\TEXT\" & trim(bCurrent) & ".VT"
							File.Name=Path
							if File.Exists() then
								sSQL="Select Tentep,mota from flownode_Tentep where Maflownode like '"& bCurrent & "'"
								Set RecT=server.CreateObject("ADODB.Recordset")
								RecT.CursorType=3
								RecT.CacheSize=5
								RecT.Open sSQL,Conn	
								bAttach=""
								if RecT.RecordCount then
									'bAttach="<hr>"
									bAttach=bAttach & "<center><Table><TR>"
									bCol=0
									Do while not RecT.EOF
											if bCol=5 then
												bAttach=bAttach & "</TR><TR>"
												bCol=0
											end if
											bAttach=bAttach & "<TD Width=135 ><A href=OpenAttach.asp?FromThuhoi=true&filename="& Session("ClsFun").mahoa(lcase(RecT("Tentep"))) & " target=New><center>"
											imgext =lcase(ExtFile(RecT("Tentep")))
											select case imgext
												case "doc"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\doc.gif"&" border=0>"
												case "xls"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\xls.gif"&" border=0>"
												case "gif","jpg","bmp","tif"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\gif.gif"&" border=0>"
												case "txt","log","bat"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\txt.gif"&" border=0>"
												case "html","htm"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\html.gif"&" border=0>"
												case "ppt"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\ppt.gif"&" border=0>"
												case "pdf"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\pdf.gif"&" border=0>"
												case "mdb"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\mdb.gif"&" border=0>"
												case "com","exe"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\exe.gif"&" border=0>"
												case "avi"
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\avi.gif"&" border=0>"
												case else
													bAttach=bAttach & "<IMG SRC="&"..\ImageAttach\other.gif"&" border=0>"
											end select
											bAttach=bAttach & "<br><font face=Arial size=2>" & RecT("Mota") & "</font></center></A></TD>"
											RecT.MoveNext
											bCol=bCol+1
									Loop
									bAttach=bAttach & "</TR></Table></center>"
									response.write bAttach
								end if
								RecT.Close
								Set RecT=nothing							
							end if
							Set File = Nothing
							'23_1
							%>
						<%else
							if RecW("trangthaixl")=1 then %>
								<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW1  %>%"><TD bgcolor=#eeeecc width="<%= bW1  %>%"><font face=Arial color=blue><Strong><%=Layten(RecW("Nguoixuly"))%></Strong></font><pre style='font-family:Arial ;font-size:14'>&#208;ang x&#7917; l&#253;...</pre></TD></Table>
							<%else%>
								<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW1  %>%"><TD bgcolor=#eeeecc width="<%= bW1  %>%"><font face=Arial color=blue><Strong><%=Layten(RecW("Nguoixuly"))%></Strong></font><pre style='font-family:Arial ;font-size:14'>Ch&#432;a x&#7917; l&#253;</pre></TD></Table>
							<%end if
						end if
					else
						if RecW("trangthaixl")=2 then%>
							<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW1  %>%"><TD bgcolor=#eeeecc width="<%= bW1  %>%"><font face=Arial color=blue><Strong><%=Layten(RecW("Nguoixuly"))%></Strong></font><pre style='font-family:Arial ;font-size:14'>&#208;&#227; xem xong</pre></TD></Table>
						<%else%>
							<Table border=0 cellspacing=0 cellpadding=0 width="<%= bW1  %>%"><TD bgcolor=#eeeecc width="<%= bW1  %>%"><font face=Arial color=blue><Strong><%=Layten(RecW("Nguoixuly"))%></Strong></font><pre style='font-family:Arial ;font-size:14'>Ch&#432;a xem</pre></TD></Table>
						<%end if
					end if%>
					<Table border=0 cellspacing=0 cellpadding=0 height=2 width='100%'><TD width='100%'></TD></Table>
	<%				RecW.MoveNext
				Loop
				'ed thphuc
				RecW.Close
				Set RecW=nothing
			end if
		end if
		Rec.MoveNext
	Loop	
	Rec.Close
	Set Rec=nothing		    					
		%>
	</form>
</Body>
<Script language=vbscript runat=server>
'L&#7845;y H&#7885; v&#224; t&#234;n c&#225;n b&#7897;
Function Layten(bMa)
	Set RecLay=server.CreateObject("ADODB.Recordset")
	RecLay.CursorType=3
	RecLay.CacheSize=5
	sSQL="Select * from canbo where macanbo like '"& bMa &"'"	
	RecLay.Open sSQL,Conn
	if RecLay.RecordCount then
		Layten=RecLay("hovaten")
	end if
	RecLay.Close
	set RecLay=nothing
End function
'T&#7893;ng h&#7907;p t&#7845;t c&#7843; c&#225;c &#253; ki&#7871;n li&#234;n quan &#273;&#7871;n d&#242;ng x&#7917; l&#253;

Function ItemLast(Item)
        Dim i
        Dim It
        Dim vt
        Dim j, Temp
        It = Item
        It = Right(It, Len(It) - 4)
        j = 1
        For i = 2 To Len(It)
            If i < Len(It) Then
                Temp = Mid(It, i, 1)
                i = i + 1
                Temp = Temp & Mid(It, i, 1)
                j = j + 1
                If Temp = "00" Then
                    ItemLast = j - 1
                    Exit For
                Else
                    If i = Len(It) Then
                        ItemLast = j
                    End If
                End If
            End If
        Next
    End Function

	Function ExtFile(filename)
		dim longfilename
		dim VtCham
		longfilename=len(filename)
		VtCham=instr(1,filename,".")
		if VtCham>0 then
			ExtFile=mid(filename,VtCham+1,longfilename-VtCham)
		end if
	End Function
    </script>